﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using vngoodlife.Util;
using System.IO;
using vngoodlife.Singleton;

namespace vngoodlife.Models
{

    //public class Gender
    //{
    //    public int Sex { get; set; }

    //    public string Name { get; set; }
    //}


    public class GeneralModels
    {
        internal string UploadArticleThumbnail(HttpPostedFileBase uploadFile,string path, string oldImageName, string newImageName)
        {
            newImageName = ThumbnailClass.ImageNameStandardization(newImageName);
            
            newImageName = newImageName + "-" + DateTime.Now.Ticks;
            string imageNameResult = "";
            if (uploadFile.FileName.Length > 0)
            {
                imageNameResult = ThumbnailClass.UploadThumbnailArticle(uploadFile,path, oldImageName, newImageName);
            }
            return imageNameResult;
        }

        /// <summary>
        /// Upload Icon Image 
        /// </summary>
        /// <param name="uploadFile"></param>
        /// <param name="physicalApplicationPath"></param>
        /// <param name="oldImage"></param>
        /// <returns></returns>
        public String MenuListUploadImage(HttpPostedFileBase uploadFile, String physicalApplicationPath, String newImageName, String oldImageName)
        {
            newImageName = ThumbnailClass.ImageNameStandardization(newImageName.ToLower()) + "-" + DateTime.Now.Ticks;
            string imageResult = "";
            if (uploadFile.FileName.Length > 0)
            {
                imageResult = ThumbnailClass.UploadImage2(uploadFile, physicalApplicationPath + "Content/images/backend/", ConstantClass._menuListIconHeight, 
                    newImageName, oldImageName);
            }
            return imageResult;
        }

        /// <summary>
        /// Upload member avatar
        /// </summary>
        /// <param name="uploadFile"></param>
        /// <param name="path"></param>
        /// <param name="oldImageName"></param>
        /// <param name="newImageName"></param>
        /// <returns></returns>
        internal string UploadMemberAvatar(HttpPostedFileBase uploadFile, string physicalApplicationPath, string newImageName, string oldImageName)
        {
            //newImageName = ThumbnailClass.ImageNameStandardization(newImageName);

            newImageName = newImageName + "-" + DateTime.Now.Ticks;
            string imageNameResult = "";
            if (uploadFile.FileName.Length > 0)
            {
                imageNameResult = ThumbnailClass.UploadImage2(uploadFile, physicalApplicationPath + "Content/images/member/", ConstantClass._memberAvatarHeight, 
                    newImageName, oldImageName);
            }
            return imageNameResult;
        }

    }
}